;; -*-scheme-*-
;; Released using Apache License, Version 2.0.
;;
;; This script is a modification of Alan Horkan's "Guides New (Percent)" script.
;; The script has been modified to add multiple guides using percentage value specified.
;; The original script adds one guide at a time.
;;
;; Location: Copy file to 'share\gimp\X.X\scripts'.

(define (script-fu-guide-new-multiple-percent image drawable direction position)
	(let* (
			(width (car (gimp-drawable-width drawable)))
			(height (car (gimp-drawable-height drawable)))
			(hstep (/ (* height position) 100))
			(wstep (/ (* width position) 100))
			)
	
		(gimp-image-undo-group-start image)
	
		(if (= direction 0)
			(set! position (/ (* height position) 100))
			(set! position (/ (* width position) 100))
		)

		(if (= direction 0) 
			;; convert position to pixel 
			(while (< position height)
				(gimp-image-add-hguide image position)
				(set! position (+ position hstep))
			)
			(while (< position width)
				(gimp-image-add-vguide image position)
				(set! position (+ position wstep))
			)
		)

		(gimp-image-undo-group-end image)
		(gimp-displays-flush)
	)
)

(script-fu-register "script-fu-guide-new-multiple-percent"
		"New Guide Multiple (by _Percent)..." 
		"Add multiple Line Guides with the specified postion. Position specified as a percent of the image size."
		"Bipin, based Alan Horkan's New Guide script and webotine.scm (http://www.jasononthe.net/pub/webotine.scm)"
		"Bipin, 2008"
		"April 2008"
		""
		SF-IMAGE "Input Image" 0 
		SF-DRAWABLE "Input Drawable" 0
		SF-OPTION "Direction" '(_"Horizontal" _"Vertical")
		SF-ADJUSTMENT "Position (in %)" '(50 0 100 1 10 0 1)
)

(script-fu-menu-register "script-fu-guide-new-multiple-percent" "<Image>/Image/Guides")

;;
;; end
;;
